#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
    int m, n, M[1000] = { 0 }, N[1000] = { 0 }, arr[2000] = { 0 };
    scanf("%d%d", &n, &m);
    int i = 0, j = 0, k = 0;

    for (i = 0; i < n; i++)
    {
        scanf("%d", &N[i]);
    }
    for (i = 0; i < m; i++)
    {
        scanf("%d", &M[i]);
    }
    for (i = 0; i < m + n; i++)
    {
        if ((N[j] < M[k] && (j < n)) | (k == m))
        {
            arr[i] = N[j];
            j++;
        }
        else
        {
            arr[i] = M[k];
            k++;
        }
        printf("%d ", arr[i]);
    }

    return 0;
}